package videoExercises;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Test7 {
    public static void main(String[] args) {
        Map<String, String> m = new HashMap<>();
        m.put("玫瑰剑士", "夏洛特");
        m.put("雷霆之王", "司空震");
        m.put("破镜之刃", "镜");
        m.put("寒月公主", "嫦娥");
        Set<Map.Entry<String, String>> entries = m.entrySet();
        //增强for循环遍历
        /*for (Map.Entry<String, String> entry : entries) {
            String key =entry.getKey();
            String value =entry.getValue();
            System.out.println(key+"="+value);
        }*/
        //迭代器遍历
        /*Iterator<Map.Entry<String, String>> iterator = entries.iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, String> next = iterator.next();
            String key = next.getKey();
            String value = next.getValue();
            System.out.println(key + "=" + value);
        }*/
        //lamada表达式遍历
        entries.forEach(a ->{
            String key=a.getKey();
            String value=a.getValue();
            System.out.println(key + "=" + value);
        });
    }
}
